<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>兴趣交友 - 发现志同道合的朋友</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome 图标 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    
    <style>
        :root {
            --primary: #4f46e5;
            --primary-light: #818cf8;
            --primary-dark: #3730a3;
            --secondary: #ec4899;
            --text-primary: #1e293b;
            --text-secondary: #64748b;
            --text-light: #94a3b8;
            --bg-light: #f8fafc;
            --bg-white: #ffffff;
            --border-light: #e2e8f0;
            --radius: 12px;
            --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            --transition: all 0.3s ease;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            background-color: var(--bg-light);
            color: var(--text-primary);
            padding-top: 56px;
            padding-bottom: 70px;
        }
        
        /* 顶部导航 */
        .top-nav {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 56px;
            background-color: var(--bg-white);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 16px;
            z-index: 1000;
            border-bottom: 1px solid var(--border-light);
        }
        
        .nav-title {
            font-size: 1.15rem;
            font-weight: 600;
            text-align: center;
            flex: 1;
        }
        
        .nav-btn {
            background: none;
            border: none;
            color: var(--text-secondary);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: var(--transition);
        }
        
        .nav-btn:hover {
            background-color: var(--bg-light);
            color: var(--primary);
        }
        
        /* 搜索栏 */
        .search-container {
            padding: 12px 16px;
            background-color: var(--bg-white);
            border-bottom: 1px solid var(--border-light);
        }
        
        .search-box {
            position: relative;
        }
        
        .search-input {
            width: 100%;
            padding: 10px 16px 10px 40px;
            border: 1px solid var(--border-light);
            border-radius: 8px;
            font-size: 0.9rem;
            background-color: var(--bg-light);
            transition: var(--transition);
        }
        
        .search-input:focus {
            outline: none;
            border-color: var(--primary-light);
            box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
        }
        
        .search-icon {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-secondary);
        }
        
        /* 筛选工具栏 */
        .filter-toolbar {
            display: flex;
            align-items: center;
            padding: 8px 16px;
            background-color: var(--bg-white);
            border-bottom: 1px solid var(--border-light);
            gap: 8px;
            overflow-x: auto;
            scrollbar-width: none;
        }
        
        .filter-toolbar::-webkit-scrollbar {
            display: none;
        }
        
        .filter-btn {
            white-space: nowrap;
            padding: 6px 12px;
            background: none;
            border: none;
            font-size: 0.85rem;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            border-radius: 6px;
            transition: var(--transition);
        }
        
        .filter-btn:hover, .filter-btn.active {
            background-color: var(--bg-light);
            color: var(--primary);
        }
        
        /* 兴趣分类标签 */
        .interest-categories {
            padding: 12px 16px;
            background-color: var(--bg-white);
            border-bottom: 1px solid var(--border-light);
            overflow-x: auto;
            scrollbar-width: none;
        }
        
        .interest-categories::-webkit-scrollbar {
            display: none;
        }
        
        .categories-container {
            display: flex;
            gap: 10px;
            white-space: nowrap;
        }
        
        .category-tag {
            padding: 6px 16px;
            border-radius: 20px;
            font-size: 0.85rem;
            background-color: var(--bg-light);
            color: var(--text-secondary);
            transition: var(--transition);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .category-tag.active {
            background-color: var(--primary);
            color: white;
        }
        
        .category-tag:hover:not(.active) {
            background-color: #e2e8f0;
        }
        
        /* 筛选面板 */
        .filter-panel {
            position: fixed;
            top: 56px;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: var(--bg-white);
            z-index: 900;
            transform: translateY(-100%);
            transition: transform 0.3s ease;
            overflow-y: auto;
        }
        
        .filter-panel.active {
            transform: translateY(0);
        }
        
        .panel-header {
            padding: 16px;
            border-bottom: 1px solid var(--border-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .panel-title {
            font-size: 1.1rem;
            font-weight: 600;
        }
        
        .panel-close {
            background: none;
            border: none;
            color: var(--text-secondary);
            font-size: 1.2rem;
        }
        
        .filter-section {
            padding: 16px;
            border-bottom: 1px solid var(--border-light);
        }
        
        .section-title {
            font-size: 0.95rem;
            font-weight: 600;
            margin-bottom: 12px;
            color: var(--text-primary);
        }
        
        .filter-options {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }
        
        .filter-option {
            padding: 6px 14px;
            border-radius: 20px;
            font-size: 0.85rem;
            background-color: var(--bg-light);
            color: var(--text-secondary);
            border: 1px solid var(--border-light);
            transition: var(--transition);
            cursor: pointer;
        }
        
        .filter-option.active {
            background-color: var(--primary);
            color: white;
            border-color: var(--primary);
        }
        
        .filter-actions {
            padding: 16px;
            display: flex;
            gap: 12px;
        }
        
        .reset-filters {
            flex: 1;
            padding: 10px 0;
            background-color: var(--bg-light);
            border: 1px solid var(--border-light);
            border-radius: 8px;
            font-size: 0.9rem;
            color: var(--text-secondary);
            transition: var(--transition);
        }
        
        .apply-filters {
            flex: 1;
            padding: 10px 0;
            background-color: var(--primary);
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            color: white;
            transition: var(--transition);
        }
        
        /* 交友列表 */
        .friends-list {
            padding: 12px 16px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        
        /* 交友项样式 */
        .friend-item {
            background-color: var(--bg-white);
            border-radius: var(--radius);
            overflow: hidden;
            box-shadow: var(--shadow);
            transition: var(--transition);
        }
        
        .friend-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
        }
        
        .friend-item.no-images .friend-content {
            padding: 16px;
        }
        
        /* 内容容器 */
        .friend-content {
            display: flex;
            gap: 12px;
            padding: 16px;
        }
        
        /* 用户头像 */
        .user-avatar {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            overflow: hidden;
            flex-shrink: 0;
            border: 2px solid var(--bg-light);
        }
        
        .user-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        /* 用户信息 */
        .user-info {
            flex: 1;
            min-width: 0;
        }
        
        .user-name {
            font-size: 1.05rem;
            font-weight: 600;
            margin-bottom: 4px;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .user-age {
            font-size: 0.85rem;
            color: var(--text-secondary);
            background-color: var(--bg-light);
            padding: 1px 8px;
            border-radius: 10px;
        }
        
        .user-location {
            font-size: 0.8rem;
            color: var(--text-secondary);
            margin-bottom: 6px;
            display: flex;
            align-items: center;
            gap: 4px;
        }
        
        .user-interests {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-bottom: 8px;
        }
        
        .interest-tag {
            padding: 2px 8px;
            background-color: rgba(79, 70, 229, 0.1);
            color: var(--primary);
            font-size: 0.75rem;
            border-radius: 4px;
        }
        
        .user-bio {
            font-size: 0.85rem;
            color: var(--text-secondary);
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            margin-bottom: 8px;
        }
        
        /* 图片容器 */
        .images-container {
            width: 100%;
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 2px;
        }
        
        .image-item {
            aspect-ratio: 1;
            overflow: hidden;
        }
        
        .image-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: var(--transition);
        }
        
        .image-item img:hover {
            transform: scale(1.05);
        }
        
        /* 互动按钮 */
        .interaction-buttons {
            display: flex;
            gap: 10px;
            margin-top: 8px;
        }
        
        .interact-btn {
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            transition: var(--transition);
            border: none;
        }
        
        .message-btn {
            flex: 1;
            background-color: var(--primary);
            color: white;
        }
        
        .message-btn:hover {
            background-color: var(--primary-dark);
        }
        
        .like-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: var(--bg-light);
            color: var(--text-secondary);
        }
        
        .like-btn:hover, .like-btn.liked {
            background-color: #fee2e2;
            color: #ef4444;
        }
        
        .more-btn {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: var(--bg-light);
            color: var(--text-secondary);
        }
        
        .more-btn:hover {
            background-color: #e2e8f0;
        }
        
        /* 加载更多 */
        .load-more {
            margin: 16px 0;
            padding: 12px;
            text-align: center;
            color: var(--primary);
            font-size: 0.9rem;
            background-color: var(--bg-white);
            border-radius: var(--radius);
            border: 1px solid var(--border-light);
            transition: var(--transition);
        }
        
        .load-more:hover {
            background-color: var(--bg-light);
        }
        
        /* 底部导航 */
        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 65px;
            background-color: var(--bg-white);
            display: flex;
            justify-content: space-around;
            align-items: center;
            border-top: 1px solid var(--border-light);
            z-index: 1000;
        }
        
        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: var(--text-secondary);
            font-size: 0.7rem;
            text-decoration: none;
        }
        
        .nav-item i {
            font-size: 1.25rem;
            margin-bottom: 4px;
        }
        
        .nav-item.active {
            color: var(--primary);
        }
        
        /* 空状态 */
        .empty-state {
            padding: 60px 20px;
            text-align: center;
            color: var(--text-secondary);
        }
        
        .empty-state i {
            font-size: 3rem;
            margin-bottom: 16px;
            color: var(--border-light);
        }
        
        /* 遮罩层 */
        .overlay {
            position: fixed;
            top: 56px;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 800;
            display: none;
        }
        
        .overlay.active {
            display: block;
        }
        
        /* 在线状态 */
        .online-indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: #10b981;
            border: 2px solid white;
            position: absolute;
            bottom: 0;
            right: 0;
        }
        
        .avatar-container {
            position: relative;
        }
    </style>
</head>
<body>
    <!-- 顶部导航 -->
    <div class="top-nav">
        <button class="nav-btn" id="backBtn">
            <i class="fas fa-arrow-left"></i>
        </button>
        <div class="nav-title">兴趣交友</div>
        <button class="nav-btn" id="settingsBtn">
            <i class="fas fa-cog"></i>
        </button>
    </div>
    
    <!-- 搜索栏 -->
    <div class="search-container">
        <div class="search-box">
            <i class="fas fa-search search-icon"></i>
            <input type="text" class="search-input" placeholder="搜索兴趣或用户...">
        </div>
    </div>
    
    <!-- 筛选工具栏 -->
    <div class="filter-toolbar">
        <button class="filter-btn active" id="allBtn">
            <i class="fas fa-users"></i>
            <span>全部</span>
        </button>
        <button class="filter-btn" id="nearbyBtn">
            <i class="fas fa-map-marker-alt"></i>
            <span>附近</span>
        </button>
        <button class="filter-btn" id="newBtn">
            <i class="fas fa-clock"></i>
            <span>最新</span>
        </button>
        <button class="filter-btn" id="onlineBtn">
            <i class="fas fa-circle"></i>
            <span>在线</span>
        </button>
        <button class="filter-btn" id="filterBtn">
            <i class="fas fa-filter"></i>
            <span>筛选</span>
        </button>
    </div>
    
    <!-- 兴趣分类标签 -->
    <div class="interest-categories">
        <div class="categories-container">
            <div class="category-tag active">
                <i class="fas fa-th"></i>
                <span>全部兴趣</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-book"></i>
                <span>阅读</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-music"></i>
                <span>音乐</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-film"></i>
                <span>电影</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-hiking"></i>
                <span>运动</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-paint-brush"></i>
                <span>艺术</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-gamepad"></i>
                <span>游戏</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-utensils"></i>
                <span>美食</span>
            </div>
            <div class="category-tag">
                <i class="fas fa-plane"></i>
                <span>旅行</span>
            </div>
        </div>
    </div>
    
    <!-- 筛选面板 -->
    <div class="filter-panel" id="filterPanel">
        <div class="panel-header">
            <div class="panel-title">筛选条件</div>
            <button class="panel-close" id="closeFilterPanel">
                <i class="fas fa-times"></i>
            </button>
        </div>
        
        <div class="filter-section">
            <div class="section-title">年龄范围</div>
            <div class="filter-options">
                <div class="filter-option active">全部</div>
                <div class="filter-option">18-22岁</div>
                <div class="filter-option">23-28岁</div>
                <div class="filter-option">29-35岁</div>
                <div class="filter-option">36-45岁</div>
                <div class="filter-option">45岁以上</div>
            </div>
        </div>
        
        <div class="filter-section">
            <div class="section-title">距离范围</div>
            <div class="filter-options">
                <div class="filter-option active">不限</div>
                <div class="filter-option">1公里内</div>
                <div class="filter-option">3公里内</div>
                <div class="filter-option">5公里内</div>
                <div class="filter-option">10公里内</div>
                <div class="filter-option">50公里内</div>
            </div>
        </div>
        
        <div class="filter-section">
            <div class="section-title">性别</div>
            <div class="filter-options">
                <div class="filter-option active">不限</div>
                <div class="filter-option">男</div>
                <div class="filter-option">女</div>
            </div>
        </div>
        
        <div class="filter-section">
            <div class="section-title">活跃时间</div>
            <div class="filter-options">
                <div class="filter-option active">全部</div>
                <div class="filter-option">今天</div>
                <div class="filter-option">本周</div>
                <div class="filter-option">本月</div>
            </div>
        </div>
        
        <div class="filter-actions">
            <button class="reset-filters" id="resetFilters">重置</button>
            <button class="apply-filters" id="applyFilters">确定</button>
        </div>
    </div>
    
    <!-- 遮罩层 -->
    <div class="overlay" id="overlay"></div>
    
    <!-- 交友列表 -->
    <div class="friends-list" id="friendsList">
        <!-- 无图交友项 -->
        <div class="friend-item no-images">
            <div class="friend-content">
                <div class="avatar-container">
                    <div class="user-avatar">
                        <img src="https://picsum.photos/id/64/100/100" alt="用户头像">
                    </div>
                    <div class="online-indicator"></div>
                </div>
                <div class="user-info">
                    <div class="user-name">
                        星辰大海
                        <span class="user-age">26岁</span>
                    </div>
                    <div class="user-location">
                        <i class="fas fa-map-marker-alt"></i>
                        <span>距离 1.2 公里</span>
                    </div>
                    <div class="user-interests">
                        <span class="interest-tag">科幻小说</span>
                        <span class="interest-tag">天文</span>
                        <span class="interest-tag">摄影</span>
                    </div>
                    <div class="user-bio">
                        天文爱好者，周末经常去郊外观星，希望认识同样对宇宙充满好奇的朋友。
                    </div>
                    <div class="interaction-buttons">
                        <button class="interact-btn message-btn">
                            <i class="fas fa-comment"></i>
                            <span>聊天</span>
                        </button>
                        <button class="interact-btn like-btn">
                            <i class="far fa-heart"></i>
                        </button>
                        <button class="interact-btn more-btn">
                            <i class="fas fa-ellipsis-h"></i>
                        </button>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 单图交友项 -->
        <div class="friend-item">
            <div class="friend-content">
                <div class="avatar-container">
                    <div class="user-avatar">
                        <img src="https://picsum.photos/id/65/100/100" alt="用户头像">
                    </div>
                </div>
                <div class="user-info">
                    <div class="user-name">
                        夏日清风
                        <span class="user-age">23岁</span>
                    </div>
                    <div class="user-location">
                        <i class="fas fa-map-marker-alt"></i>
                        <span>距离 3.5 公里</span>
                    </div>
                    <div class="user-interests">
                        <span class="interest-tag">徒步</span>
                        <span class="interest-tag">露营</span>
                        <span class="interest-tag">自然</span>
                    </div>
                    <div class="user-bio">
                        喜欢亲近自然，每个月都会组织一次徒步活动，欢迎加入我们的户外小组！
                    </div>
                </div>
            </div>
            <div class="images-container">
                <div class="image-item">
                    <img src="https://picsum.photos/id/29/300/300" alt="用户分享的图片">
                </div>
                <div class="image-item" style="display: none;"></div>
                <div class="image-item" style="display: none;"></div>
            </div>
        </div>
        
        <!-- 三图交友项 -->
        <div class="friend-item">
            <div class="friend-content">
                <div class="avatar-container">
                    <div class="user-avatar">
                        <img src="https://picsum.photos/id/91/100/100" alt="用户头像">
                    </div>
                    <div class="online-indicator"></div>
                </div>
                <div class="user-info">
                    <div class="user-name">
                        咖啡不加糖
                        <span class="user-age">31岁</span>
                    </div>
                    <div class="user-location">
                        <i class="fas fa-map-marker-alt"></i>
                        <span>距离 5.8 公里</span>
                    </div>
                    <div class="user-interests">
                        <span class="interest-tag">咖啡</span>
                        <span class="interest-tag">烘焙</span>
                        <span class="interest-tag">阅读</span>
                    </div>
                    <div class="user-bio">
                        咖啡师一枚，喜欢研究各种咖啡配方，偶尔烘焙面包，寻找可以一起品尝咖啡的朋友。
                    </div>
                </div>
            </div>
            <div class="images-container">
                <div class="image-item">
                    <img src="https://picsum.photos/id/431/300/300" alt="用户分享的图片">
                </div>
                <div class="image-item">
                    <img src="https://picsum.photos/id/225/300/300" alt="用户分享的图片">
                </div>
                <div class="image-item">
                    <img src="https://picsum.photos/id/425/300/300" alt="用户分享的图片">
                </div>
            </div>
        </div>
        
        <!-- 两图交友项 -->
        <div class="friend-item">
            <div class="friend-content">
                <div class="avatar-container">
                    <div class="user-avatar">
                        <img src="https://picsum.photos/id/237/100/100" alt="用户头像">
                    </div>
                </div>
                <div class="user-info">
                    <div class="user-name">
                        音乐漫游者
                        <span class="user-age">28岁</span>
                    </div>
                    <div class="user-location">
                        <i class="fas fa-map-marker-alt"></i>
                        <span>距离 8.3 公里</span>
                    </div>
                    <div class="user-interests">
                        <span class="interest-tag">独立音乐</span>
                        <span class="interest-tag">Livehouse</span>
                        <span class="interest-tag">吉他</span>
                    </div>
                    <div class="user-bio">
                        独立音乐爱好者，周末经常去看演出，自己也在学吉他，希望认识同样喜欢音乐的朋友。
                    </div>
                </div>
            </div>
            <div class="images-container">
                <div class="image-item">
                    <img src="https://picsum.photos/id/1082/300/300" alt="用户分享的图片">
                </div>
                <div class="image-item">
                    <img src="https://picsum.photos/id/1074/300/300" alt="用户分享的图片">
                </div>
                <div class="image-item" style="display: none;"></div>
            </div>
        </div>
        
        <!-- 加载更多 -->
        <div class="load-more" id="loadMore">
            加载更多
        </div>
    </div>
    
    <!-- 底部导航 -->
    <div class="bottom-nav">
        <a href="#" class="nav-item">
            <i class="fas fa-home"></i>
            <span>首页</span>
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-compass"></i>
            <span>发现</span>
        </a>
        <a href="#" class="nav-item active">
            <i class="fas fa-heart"></i>
            <span>交友</span>
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-comment"></i>
            <span>消息</span>
        </a>
        <a href="#" class="nav-item">
            <i class="fas fa-user"></i>
            <span>我的</span>
        </a>
    </div>
    
    <!-- Bootstrap JS Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
        // DOM元素
        const backBtn = document.getElementById("backBtn");
        const settingsBtn = document.getElementById("settingsBtn");
        const filterBtn = document.getElementById("filterBtn");
        const allBtn = document.getElementById("allBtn");
        const nearbyBtn = document.getElementById("nearbyBtn");
        const newBtn = document.getElementById("newBtn");
        const onlineBtn = document.getElementById("onlineBtn");
        const filterPanel = document.getElementById("filterPanel");
        const closeFilterPanel = document.getElementById("closeFilterPanel");
        const overlay = document.getElementById("overlay");
        const resetFilters = document.getElementById("resetFilters");
        const applyFilters = document.getElementById("applyFilters");
        const filterButtons = document.querySelectorAll(".filter-btn");
        const categoryTags = document.querySelectorAll(".category-tag");
        const loadMoreBtn = document.getElementById("loadMore");
        const friendsList = document.getElementById("friendsList");
        const searchInput = document.querySelector(".search-input");
        
        // 更多用户数据
        const moreUsers = [
            {
                name: "书香门第",
                age: 35,
                avatar: "https://picsum.photos/id/177/100/100",
                location: "距离 2.7 公里",
                interests: ["文学", "历史", "书法"],
                bio: "大学文学老师，喜欢收集古籍，每周六在图书馆有读书会，欢迎参加。",
                images: [],
                online: false
            },
            {
                name: "篮球小子",
                age: 22,
                avatar: "https://picsum.photos/id/338/100/100",
                location: "距离 4.2 公里",
                interests: ["篮球", "健身", "电竞"],
                bio: "篮球爱好者，每天晚上都会去球场，寻找固定队友组建球队。",
                images: [
                    "https://picsum.photos/id/1058/300/300"
                ],
                online: true
            },
            {
                name: "美食家",
                age: 30,
                avatar: "https://picsum.photos/id/453/100/100",
                location: "距离 6.5 公里",
                interests: ["美食", "烹饪", "探店"],
                bio: "喜欢尝试各种美食，自己也喜欢下厨，有一个美食分享小组，欢迎加入。",
                images: [
                    "https://picsum.photos/id/292/300/300",
                    "https://picsum.photos/id/431/300/300"
                ],
                online: false
            }
        ];
        
        // 当前筛选条件
        const currentFilters = {
            type: "全部",
            category: "全部兴趣",
            age: "全部",
            distance: "不限",
            gender: "不限",
            activity: "全部",
            search: ""
        };
        
        // 初始化
        function init() {
            setupEventListeners();
        }
        
        // 设置事件监听
        function setupEventListeners() {
            // 返回按钮
            backBtn.addEventListener("click", () => {
                history.back();
            });
            
            // 设置按钮
            settingsBtn.addEventListener("click", () => {
                alert("打开设置页面");
            });
            
            // 筛选按钮
            filterBtn.addEventListener("click", () => {
                toggleFilterPanel();
                setActiveFilterBtn(filterBtn);
            });
            
            // 分类筛选按钮
            [allBtn, nearbyBtn, newBtn, onlineBtn].forEach(btn => {
                btn.addEventListener("click", function() {
                    closeFilterPanel();
                    currentFilters.type = this.querySelector("span").textContent;
                    setActiveFilterBtn(this);
                    applyFilters();
                });
            });
            
            // 关闭筛选面板
            closeFilterPanel.addEventListener("click", closeFilterPanel);
            
            // 遮罩层点击关闭筛选面板
            overlay.addEventListener("click", closeFilterPanel);
            
            // 兴趣分类标签点击
            categoryTags.forEach(tag => {
                tag.addEventListener("click", function() {
                    // 移除其他标签的活跃状态
                    categoryTags.forEach(t => t.classList.remove("active"));
                    // 添加当前标签的活跃状态
                    this.classList.add("active");
                    
                    // 更新筛选条件
                    currentFilters.category = this.querySelector("span").textContent;
                    
                    // 应用筛选
                    applyFilters();
                });
            });
            
            // 筛选选项点击
            document.querySelectorAll(".filter-option").forEach(option => {
                option.addEventListener("click", function() {
                    // 移除同组其他选项的活跃状态
                    const parent = this.parentElement;
                    parent.querySelectorAll(".filter-option").forEach(opt => opt.classList.remove("active"));
                    // 添加当前选项的活跃状态
                    this.classList.add("active");
                });
            });
            
            // 应用筛选
            applyFilters.addEventListener("click", function() {
                const age = filterPanel.querySelectorAll(".filter-section")[0]
                    .querySelector(".filter-option.active").textContent;
                const distance = filterPanel.querySelectorAll(".filter-section")[1]
                    .querySelector(".filter-option.active").textContent;
                const gender = filterPanel.querySelectorAll(".filter-section")[2]
                    .querySelector(".filter-option.active").textContent;
                const activity = filterPanel.querySelectorAll(".filter-section")[3]
                    .querySelector(".filter-option.active").textContent;
                
                currentFilters.age = age;
                currentFilters.distance = distance;
                currentFilters.gender = gender;
                currentFilters.activity = activity;
                
                closeFilterPanel();
                applyFilters();
            });
            
            // 重置筛选
            resetFilters.addEventListener("click", function() {
                filterPanel.querySelectorAll(".filter-section").forEach(section => {
                    section.querySelectorAll(".filter-option").forEach(opt => opt.classList.remove("active"));
                    section.querySelector(".filter-option:first-child").classList.add("active");
                });
            });
            
            // 加载更多
            loadMoreBtn.addEventListener("click", loadMoreUsers);
            
            // 搜索功能
            searchInput.addEventListener("input", (e) => {
                const keyword = e.target.value.trim();
                currentFilters.search = keyword;
                
                // 延迟搜索，避免频繁触发
                clearTimeout(window.searchTimeout);
                window.searchTimeout = setTimeout(() => {
                    applyFilters();
                }, 500);
            });
            
            // 点赞按钮点击
            document.addEventListener("click", (e) => {
                if (e.target.closest(".like-btn")) {
                    const likeBtn = e.target.closest(".like-btn");
                    const icon = likeBtn.querySelector("i");
                    
                    likeBtn.classList.toggle("liked");
                    
                    if (likeBtn.classList.contains("liked")) {
                        icon.classList.remove("far");
                        icon.classList.add("fas");
                        showToast("已喜欢");
                    } else {
                        icon.classList.remove("fas");
                        icon.classList.add("far");
                        showToast("取消喜欢");
                    }
                }
                
                // 聊天按钮点击
                if (e.target.closest(".message-btn")) {
                    const friendItem = e.target.closest(".friend-item");
                    const userName = friendItem.querySelector(".user-name").textContent.trim();
                    alert(`开始与 ${userName} 聊天`);
                }
                
                // 更多按钮点击
                if (e.target.closest(".more-btn")) {
                    showToast("更多操作选项");
                }
                
                // 图片点击
                if (e.target.closest(".image-item img")) {
                    const imgSrc = e.target.getAttribute("src");
                    alert(`查看大图: ${imgSrc}`);
                }
            });
        }
        
        // 切换筛选面板显示/隐藏
        function toggleFilterPanel() {
            if (filterPanel.classList.contains("active")) {
                closeFilterPanel();
            } else {
                filterPanel.classList.add("active");
                overlay.classList.add("active");
            }
        }
        
        // 关闭筛选面板
        function closeFilterPanel() {
            filterPanel.classList.remove("active");
            overlay.classList.remove("active");
        }
        
        // 设置活跃的筛选按钮
        function setActiveFilterBtn(btn) {
            filterButtons.forEach(b => b.classList.remove("active"));
            btn.classList.add("active");
        }
        
        // 应用筛选条件
        function applyFilters() {
            // 显示加载状态
            showLoading();
            
            // 模拟筛选延迟
            setTimeout(() => {
                // 在实际应用中，这里会根据currentFilters从服务器请求数据
                console.log("应用筛选条件:", currentFilters);
                
                hideLoading();
            }, 800);
        }
        
        // 加载更多用户
        function loadMoreUsers() {
            showLoading();
            
            // 模拟加载延迟
            setTimeout(() => {
                // 移除加载更多按钮
                friendsList.removeChild(loadMoreBtn);
                
                // 添加新用户
                moreUsers.forEach(user => {
                    const userElement = createUserElement(user);
                    friendsList.appendChild(userElement);
                });
                
                // 重新添加加载更多按钮
                friendsList.appendChild(loadMoreBtn);
                hideLoading();
            }, 1000);
        }
        
        // 创建用户元素
        function createUserElement(user) {
            const userElement = document.createElement("div");
            
            // 确定用户项样式（有无图片）
            let hasImages = user.images && user.images.length > 0;
            userElement.className = `friend-item ${!hasImages ? 'no-images' : ''}`;
            
            // 构建兴趣标签HTML
            let interestsHtml = "";
            user.interests.forEach(interest => {
                interestsHtml += `<span class="interest-tag">${interest}</span>`;
            });
            
            // 构建图片HTML
            let imagesHtml = "";
            if (hasImages) {
                imagesHtml = `<div class="images-container">`;
                
                // 最多显示3张图片
                const displayImages = user.images.slice(0, 3);
                
                displayImages.forEach((img, index) => {
                    imagesHtml += `
                        <div class="image-item ${index >= displayImages.length ? 'd-none' : ''}">
                            <img src="${img}" alt="${user.name}分享的图片">
                        </div>
                    `;
                });
                
                // 补充空白项以保持网格布局
                for (let i = displayImages.length; i < 3; i++) {
                    imagesHtml += `<div class="image-item" style="display: none;"></div>`;
                }
                
                imagesHtml += `</div>`;
            }
            
            // 在线状态指示器
            const onlineIndicator = user.online ? `<div class="online-indicator"></div>` : "";
            
            // 组装用户项HTML
            userElement.innerHTML = `
                <div class="friend-content">
                    <div class="avatar-container">
                        <div class="user-avatar">
                            <img src="${user.avatar}" alt="${user.name}的头像">
                        </div>
                        ${onlineIndicator}
                    </div>
                    <div class="user-info">
                        <div class="user-name">
                            ${user.name}
                            <span class="user-age">${user.age}岁</span>
                        </div>
                        <div class="user-location">
                            <i class="fas fa-map-marker-alt"></i>
                            <span>${user.location}</span>
                        </div>
                        <div class="user-interests">
                            ${interestsHtml}
                        </div>
                        <div class="user-bio">
                            ${user.bio}
                        </div>
                        ${!hasImages ? `
                            <div class="interaction-buttons">
                                <button class="interact-btn message-btn">
                                    <i class="fas fa-comment"></i>
                                    <span>聊天</span>
                                </button>
                                <button class="interact-btn like-btn">
                                    <i class="far fa-heart"></i>
                                </button>
                                <button class="interact-btn more-btn">
                                    <i class="fas fa-ellipsis-h"></i>
                                </button>
                            </div>
                        ` : ''}
                    </div>
                </div>
                ${hasImages ? `
                    ${imagesHtml}
                    <div class="friend-content" style="padding-top: 0; padding-bottom: 16px;">
                        <div class="user-avatar" style="visibility: hidden;"></div>
                        <div class="user-info">
                            <div class="interaction-buttons">
                                <button class="interact-btn message-btn">
                                    <i class="fas fa-comment"></i>
                                    <span>聊天</span>
                                </button>
                                <button class="interact-btn like-btn">
                                    <i class="far fa-heart"></i>
                                </button>
                                <button class="interact-btn more-btn">
                                    <i class="fas fa-ellipsis-h"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                ` : ''}
            `;
            
            return userElement;
        }
        
        // 显示加载状态
        function showLoading() {
            loadMoreBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 加载中...';
            loadMoreBtn.style.pointerEvents = "none";
        }
        
        // 隐藏加载状态
        function hideLoading() {
            loadMoreBtn.innerHTML = "加载更多";
            loadMoreBtn.style.pointerEvents = "auto";
        }
        
        // 显示提示消息
        function showToast(message) {
            // 检查是否已有toast，有则移除
            const existingToast = document.querySelector(".toast-message");
            if (existingToast) {
                existingToast.remove();
            }
            
            // 创建新toast
            const toast = document.createElement("div");
            toast.className = "toast-message";
            toast.style.position = "fixed";
            toast.style.bottom = "80px";
            toast.style.left = "50%";
            toast.style.transform = "translateX(-50%)";
            toast.style.backgroundColor = "rgba(0, 0, 0, 0.7)";
            toast.style.color = "white";
            toast.style.padding = "8px 16px";
            toast.style.borderRadius = "4px";
            toast.style.fontSize = "0.9rem";
            toast.style.zIndex = "9999";
            toast.textContent = message;
            
            // 添加到页面
            document.body.appendChild(toast);
            
            // 3秒后移除
            setTimeout(() => {
                toast.style.opacity = "0";
                toast.style.transition = "opacity 0.3s ease";
                setTimeout(() => {
                    toast.remove();
                }, 300);
            }, 3000);
        }
        
        // 初始化页面
        document.addEventListener("DOMContentLoaded", init);
    </script>
</body>
</html>
